<template>
  <div class="topSubject">
    <div class="topName">
      <font>{{ topObject.topName }}</font>
    </div>
    <div
      v-for="(item, index) in topObject.comicList"
      :key="item.id"
      :class="[
        'topComicInfo',
        {
          first: index === 0,
        },
      ]"
    >
      <div class="img">
        <a @click="imgClick(item)"><img :src="item.imgPath" alt="" /></a>
      </div>
      <div class="rank">
        <span
          :class="[
            { firstRank: index === 0 },
            { secondRank: index === 1 },
            { thirdRank: index === 2 },
          ]"
          >{{ index + 1 }}</span
        >
      </div>
      <div class="comicInfo">
        <a @click="imgClick(item)"
          ><font class="title">{{ item.title }}</font></a
        >
        <font class="content">{{ item.content }}</font>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'IndexMainTopCom',
  props: {
    topObject: {
      type: Object
    }
  },
  methods: {
    imgClick (item) {
      this.$router.push({
        path: '/comicInfo',
        query: {
          id: item.id
        }
      });
    }
  }

};
</script>

<style lang="less" scoped>
.topSubject {
  width: 100%;
  height: 100%;
  .topName {
    width: 100%;
    height: 35px;
    font {
      font-size: 20px;
      font-weight: bold;
      margin-left: 5px;
    }
  }
  .topComicInfo {
    width: 100%;
    height: 70px;
    float: left;
    margin-top: 5px;
    display: flex;
    flex-direction: row;
    padding-left: 5px;
    box-sizing: border-box;
    .img {
      width: 100px;
      height: 100%;
      overflow: hidden;
      float: left;
      img {
        width: 100%;
      }
    }
    .rank {
      height: 100%;
      width: 25px;
      float: left;
      display: flex;
      justify-content: center;
      span {
        font-size: 17px;
        font-weight: bold;
        text-align: center;
        line-height: 20px;
        display: block;
        width: 20px;
        height: 20px;
        background-color: #f7f7f7;
        border-radius: 50%;
      }
      .firstRank {
        background-color: #feda00;
        color: #ffffff;
      }
      .secondRank {
        background-color: #feaf00;
        color: #ffffff;
      }
      .thirdRank {
        background-color: #fe8f00;
        color: #ffffff;
      }
    }
    .comicInfo {
      flex: 1;
      overflow: hidden;
      a {
        list-style: none;
        color: black;
        display: block;
        width: 100%;
        height: 20px;

        .title {
          font-size: 16px;
          font-weight: bold;
          display: block;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
        }
      }
      .content {
        font-size: 14px;
        display: block;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        color: #a7a7a7;
      }
    }
  }
  .first {
    margin-top: 0;
  }
}
</style>>
